<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="../../common/operation_forbid.jsp"%>
<%@include file="../../common/jsVersion.jsp"%>
<!DOCTYPE html >
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="jypath" value="${pageContext.request.contextPath}" />
<html>
<head>

<link rel="stylesheet" href="${jypath}/static/css/strip.css" />
<script type="text/javascript" src="${jypath}/static/js/strip.min.js"></script>

</head>
<body >

	<div class="nav-view margin-bottom-10 border-bottom" id="tabDiv">
		<a id="detail_1" name="1" onclick="toDetail('toProjectInfo', 1)" class="btn-nav-default activi" >项目信息</a>
		<a id="detail_2" name="2" onclick="toDetail('toSaleView', 2)" class="btn-nav-default" >销售情况查看</a>
		<a id="detail_3" name="3" onclick="toDetail('toStageBrowse', 3)" class="btn-nav-default" >项目下各分期信息浏览</a>
		<a id="detail_4" name="4" onclick="toDetail('toBudingIndust',4)" class="btn-nav-default" >项目下各楼栋业态及汇总</a>
	</div>
	<div id="maincontent"  style="height:100%;overflow-y:scroll;">
	</div>
</body>
</html>



<script type="text/javascript">
	var jypath = '${jypath}';
	$(function(){
		toDetail('toProjectInfo', 1);
		$("#detail_1").addClass("active");
		
	});

	
	function toDetail(tabUrl, tabIndex) {
			if(tabIndex==1){
				$("#detail_1").addClass("active");
				$("#detail_2").removeClass("active");
				$("#detail_3").removeClass("active");
				$("#detail_4").removeClass("active");
			}else if(tabIndex==2){
				$("#detail_1").removeClass("active");
				$("#detail_2").addClass("active");
				$("#detail_3").removeClass("active");
				$("#detail_4").removeClass("active");
			}else if(tabIndex==3){
				$("#detail_1").removeClass("active");
				$("#detail_2").removeClass("active");
				$("#detail_3").addClass("active");
				$("#detail_4").removeClass("active");
			}else if(tabIndex==4){
				$("#detail_1").removeClass("active");
				$("#detail_2").removeClass("active");
				$("#detail_3").removeClass("active");
				$("#detail_4").addClass("active");
			}
		    var params={
		    	id:'${id}',
		    	projectId:'${id}',
		    	buildIndustType:'2',
		    	industType:'1'
		    };
		   
		    $.ajax({
		         url: "${jypath}/estate/project/" + tabUrl, 
		         dataType: "text",
		         type: "GET",
		         data: params, 
		         success: function(result){ 
		            $("#maincontent").html(result); 
		         }
		      });
		    
		}
	function deleteIndust(obj,flag){
		layer.confirm('确定删除?', {
		  btn: ['确定','取消'] //按钮
		}, function(){
			var industId = $(obj).attr("id");
			var url = "${jypath}/estate/project/deleteIndustInfo";
			var params = {
				id:industId
			};
			$.ajax({
				type: "POST",
	            url: url,
	            data: params,
	            dataType: "json",
	            success: function(data){
	            	if(data.res=="1"){
	            		layer.alert("删除成功");
	            		if(flag){
	            			toDetail('toSaleView', 2);
	            		}else{
	            			premisesIndust();
	            		}
	            		
	            	}else{
	            		layer.alert("删除失败");
	            	}
	            }
			});
		  
		}, function(){
		  
		});
		
	
	}
	
	function setProjectHouseType(){
		var url="${jypath}/estate/projectHouseType/index?projectId=${id}&menu=${menu}";
	  	window.location.href=url;
	}
	function toBatchUpdate(){
		var url="${jypath}/estate/projectRoom/toBatchUpdate?projectId=${id}";
		window.location.href=url;
	}
	function toBatchImport(){
		var id = "${id}"
	   	var tabKey = "batchImp_" + id;
       	var url = "/estate/import/indexLC?id=${id}&menu=${menu}";
       	parent.openMenu("0",tabKey,"","批量导入",url);
	}
	function toBack(){
	 	var url="${jypath}/estate/project/index?menu="+$("#menuId").val();
	   	window.location.href=url;
	}
	function sendStaticSalePmo(){
		$.ajax({
			 url: "${jypath}/estate/project/sendStaticSalePmo",
		     type: "post",
		     dataType:'json', 
		     async:false,
		     data:{"projectId":"${id}"},
		     success:function(data){
		    	 alert(data.success);
		    	 var flag = "alert alert-warning fade in";
			  	 var msg = "推送失败";
			  	 if(data.success == true){
			  		 flag = "alert alert-success fade in";
			  		 msg = "推送成功";
			  	 } 
			  	 var html = '<div id="myAlert" class="'+flag+'">'
			  		      + '<a href="#" class="close" data-dismiss="alert">&times;</a>'
			  		      + '<strong>'+msg+'</strong></div>';
	  	 		 $("#divAlert").html(html);
	  	 		$("#myAlert").alert("close");
  	 			 setTimeout('$("#myAlert").alert("close");',2000);
		     }
	    });
	}
		
			
			
	function showImg(obj){
		var checkImg = $(obj).attr("src");
		var array = new Array();
		array.push({ url:checkImg,caption: getFileName(checkImg),options:{side:'left'}});
		var allImg =  $(obj).parent().children();
		for(var i=0;i<allImg.length;i++){
	 		if(allImg.eq(i).attr("src")!=checkImg){
	 			array.push({ url:allImg.eq(i).attr("src") , caption: getFileName(allImg.eq(i).attr("src")),options:{side:'left'}});
	 		}
	 	}
		Strip.show(array);
  	}
  	function replaceFileUrl(ftpUrl){
    	if(ftpUrl==null||ftpUrl==""){
    		return ftpUrl;
    	}
    	//取得文件明
    	var fileName=ftpUrl.substring(ftpUrl.indexOf("?")+1,ftpUrl.length);
    	ftpUrl=ftpUrl.replace(new RegExp("/","gm"),"?");  
    	ftpUrl=ftpUrl.substring(0,ftpUrl.indexOf("?fileName="));
    	return "?fileUrl="+ftpUrl+"&"+fileName;
    }
			    
	function getFileName(ftpUrl){
		var fileName = ftpUrl.substring(ftpUrl.indexOf("=")+1,ftpUrl.length);
		var aLink = replaceFileUrl(ftpUrl);
		var abtn = "<a href='${jypath}/common/file/downloadFile"+aLink+"'>"+fileName+"</a>";
		return abtn;
	}
			
</script>